package com.apes.framework.plugin.scheduler;

import com.apes.framework.jpa.repository.CustomRepository;
import org.springframework.data.domain.Pageable;

import java.util.Date;
import java.util.List;

/**
 * @author xul
 * @create 2018-01-23 16:07
 */
public interface TaskRepository extends CustomRepository<Task, String> {

    /**
     * 取最后更新的任务，用于获取最大时间戳
     */
    Task findFirstByOrderByLastUpdatedStampDesc();

    List<Task> findByLastUpdatedStampLessThanEqualOrderByLastUpdatedStampAsc(Date maxTimestamp, Pageable pageable);

    List<Task> findByLastUpdatedStampGreaterThanAndLastUpdatedStampLessThanEqualOrderByLastUpdatedStampAsc(Date minTimestamp, Date maxTimestamp, Pageable pageable);

}
